package com.sg.service.biz.component.impl;

import com.sg.common.util.RedisUtil;
import com.sg.dto.biz.component.req.DeleteTempCloneResultEtcComReqDto;
import com.sg.dto.biz.component.req.DeleteTempSchemeConrelComReqDto;
import com.sg.dto.biz.component.req.QueryEvaTempRetConfResultListComReqDto;
import com.sg.dto.biz.component.res.DeleteTempCloneResultEtcComRespDto;
import com.sg.dto.biz.component.res.DeleteTempSchemeConrelComRespDto;
import com.sg.dto.biz.component.res.QueryEvaTempRetConfResultListComRespDto;
import com.sg.service.biz.component.ConfSchemeService;
import com.sg.service.biz.component.SchemeOpenRecordService;
import com.sg.common.exception.Assert;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class EvaThemeServiceImpl
        implements com.wicket.okrcomponent.biz.service.EvaThemeService {

    @Resource
    private RedisUtil redisUtil;
    @Resource
    private ConfSchemeService confSchemeService;
    @Resource
    private SchemeOpenRecordService schemeOpenRecordService;

    /**
     * D3删除模板克隆答案等相关(公共)[5619]
     * gen by moon at 1/7/2023, 1:41:23 AM
     */
    @Trace(operationName = "D3删除模板克隆答案等相关(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public DeleteTempCloneResultEtcComRespDto deleteTempCloneResultEtcCom(DeleteTempCloneResultEtcComReqDto reqDto) {


        //virtualUsage D2-3查询评价模板相关配置答案列表(公共)  26588
        QueryEvaTempRetConfResultListComRespDto queryEvaTempRetConfResultListComRespDto = null;
        QueryEvaTempRetConfResultListComReqDto queryEvaTempRetConfResultListComReqDto = new QueryEvaTempRetConfResultListComReqDto();
        queryEvaTempRetConfResultListComReqDto.setResultAspObjType("EVA_TEMP");//sourceId:586468_1_26588
        queryEvaTempRetConfResultListComReqDto.setIsPlatData("FALSE");//sourceId:586469_1_26588
        if (reqDto != null) {
            queryEvaTempRetConfResultListComReqDto.setResultAspObjId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:586467_1_26588
        }

        /*D2-3查询评价模板相关配置答案列表(公共)[4847]   */
        Assert.isNull(queryEvaTempRetConfResultListComReqDto.getResultAspObjId(), "D3删除模板克隆答案等相关(公共)-D2-3查询评价模板相关配置答案列表(公共)-答案归属对象ID不能为空", false);
        Assert.isNull(queryEvaTempRetConfResultListComReqDto.getResultAspObjType(), "D3删除模板克隆答案等相关(公共)-D2-3查询评价模板相关配置答案列表(公共)-答案归属对象类型不能为空", false);
        Assert.isNull(queryEvaTempRetConfResultListComReqDto.getIsPlatData(), "D3删除模板克隆答案等相关(公共)-D2-3查询评价模板相关配置答案列表(公共)-是否标准答案不能为空", false);
        queryEvaTempRetConfResultListComRespDto = confSchemeService.queryEvaTempRetConfResultListCom(queryEvaTempRetConfResultListComReqDto);


        if ((queryEvaTempRetConfResultListComRespDto != null && queryEvaTempRetConfResultListComRespDto.getConfItemResultList() != null && queryEvaTempRetConfResultListComRespDto.getConfItemResultList().size() > 0)) {
            //if(D2-3查询评价模板相关配置答案列表(公共).方案下选项配置结果列表数据集条数 大于 0)  26591

            DeleteTempSchemeConrelComRespDto deleteTempSchemeConrelComRespDto = null;
            DeleteTempSchemeConrelComReqDto deleteTempSchemeConrelComReqDto = new DeleteTempSchemeConrelComReqDto();
            if (reqDto != null) {
                deleteTempSchemeConrelComReqDto.setConfSchemeId(reqDto.getConfSchemeId());//SimpleFieldAssign//sourceId:586474_1_26593
                deleteTempSchemeConrelComReqDto.setEvaluationTemplateId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:586472_1_26593
            }

            /*D2-3删除模板方案配置关系(公共)[4837]   */
            Assert.isNull(deleteTempSchemeConrelComReqDto.getConfSchemeId(), "D3删除模板克隆答案等相关(公共)-D2-3删除模板方案配置关系(公共)-配置方案ID 不能为空", false);
            Assert.isNull(deleteTempSchemeConrelComReqDto.getEvaluationTemplateId(), "D3删除模板克隆答案等相关(公共)-D2-3删除模板方案配置关系(公共)-冗余评价模板ID不能为空", false);
            deleteTempSchemeConrelComRespDto = schemeOpenRecordService.deleteTempSchemeConrelCom(deleteTempSchemeConrelComReqDto);


        }
        DeleteTempCloneResultEtcComRespDto retData = new DeleteTempCloneResultEtcComRespDto();


        return retData;
    }
    //
}
